<?php
namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Request;
class Party extends Controller
{
    public function index()
    {
        $list = Db::table('chen_user')
            ->field(['id', 'tel','province','sex','age','name','status'])
            ->order(['id' => 'ASC'])
            ->select();
        

        // dump($list);
        return view('party/user', [
            'list' => $list
        ]);
    }

    public function done($state)
    {
        
       
        $id =  input('id');
        $row = Db::table('chen_user')
            ->where('id','eq',$id)
            ->find();
        dump($row['status']);
        if ($row['status'] == 0) {
            $info['status'] = 1;
            $data = Db::table('chen_user')
                 ->where('id','eq',$row['id'])
                 ->update([
                    'status' =>$info['status'], 
                ]);
            $info['title'] = '修改成功';
            return json($info);

        }else{
            $info['status'] = 0;
            $data = Db::table('chen_user')
                 ->where('id','eq',$row['id'])
                 ->update([
                    'status' =>$info['status'],
            ]);
            $info['title'] = '修改成功';
            return json($info);

        }
    }


   

}